<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="canonical" href="https://jamesfengcao.gitlab.io/uweb/en/filecap/" />
    
    <link rel="stylesheet" href="../style.css#" type="text/css" />
    <title>Custom file handling</title>
    <script>
      function findLang(){
        let href = location.href;
        for(let i=href.length-1;i>0;i--){
          if('/'==href.charAt(i) && '/'==href.charAt(i-3))
            return i;
        }
        return 0;
      }
      function nav2(page){
        let i = findLang();
        location.href = location.href.substring(0,i+1)+page;
      }
      function nav2Lang(lang){
        let i = findLang();
        let href = location.href;
        location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
      }
    </script>
  </head>
  <body>
    <header class='header'>
      <a class="logo" href="javascript:void(0)" onclick="return nav2('index.html#')">Home</a> <a class="logo" href="javascript:void(0)" onclick="return nav2('tags/index.html#')">Tags</a>
      
        
          <a class="logo" href="javascript:void(0)" onclick="return nav2Lang('zh')">简体中文</a>
        
      
      <nav>
      </nav>
    </header>
    <br />
    
<div class="container">
  <h1 class="title">Custom file handling
    <br>
    <span class="subtitle"></span>
  </h1>
  <ul class="tags">
    
    <li><a href="../tags/termux/index.html#">termux</a> </li>
    
    <li><a href="../tags/curl/index.html#">curl</a> </li>
    
  </ul>
  <p>Long press the settings button, check the option &quot;custom file handling&quot; to enable the functionality.</p>
<p>The custom file handling configuration file is &quot;default.filecap&quot;, each line of it has the format as follows:<br>
[file extension]:[mimetype]:[command line]</p>
<p>The &quot;[file extension]&quot; part can have at most two-segment of extensions such as &quot;txt.xz&quot;,&quot;html.gz&quot;.<br>
&quot;[mimetype]&quot; indicates the type of &quot;[command line]&quot; output.<br>
&quot;[command line]&quot; is same as the one in <a href="../cmds/index.html#">default.cmds</a>. The most often used replacements are:<br>
%u (url), %U (urlencoded url), %c (cookie), %p (site password, curl format).</p>
<p>default.filecap example:</p>
<pre><code>txt:text/html:curl %p "%u"
mp3:text/html:echo '&lt;audio controls width=100% height=100%>&lt;source src="%u">&lt;/audio>'
m4b:text/html:echo '&lt;audio controls width=100% height=100%>&lt;source src="%u">&lt;/audio>'
m3u8:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
mp4:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
mkv:text/html:echo '&lt;video controls width=100% height=100%>&lt;source src="%u">&lt;/video>'
doc:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
xls:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
ppt:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
docx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
xlsx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
pptx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
xz:text/plain:curl %p "%u"|xz -d --</code></pre>
<p>Examples for <a href="../html5/index.html#">html5 application</a>:</p>
<pre><code>pdf:uweb:echo file:///data/data/info.torapp.uweb/files/app/pdf.js/web/viewer.html?file=%u
djvu:uweb:echo file:///data/data/info.torapp.uweb/files/app/djvu.html?url=%u
epub:uweb:echo file:///data/data/info.torapp.uweb/files/app/reader/index.html#?bookPath==%u</code></pre>

</div>
<p>Last Modified: 2 April 2024<br>
add js function in README<br>
<pre></pre>
</p>

<script id='jsgiscus'
  src='https://giscus.app/client.js'
  data-repo="torappinfo/uweb"
  data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
  data-category="Announcements"
  data-category-id="DIC_kwDOEgNLGc4CQjsh"
  data-mapping="title"
  data-strict="0"
  data-reactions-enabled="1"
  data-emit-metadata="0"
  data-input-position="top"
  data-theme="light"
  data-lang="en"
  data-loading="lazy"
  crossorigin="anonymous" async>
</script>

    <footer class="site-footer">
      <div class="container">
        &copy; 2018-2025 Richard H. Cao
      </div>
    </footer>
    <!-- This document is licensed under the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at <https://www.gnu.org/licenses/>. -->


  </body>
</html>
